#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
using namespace std;

int n;
long long a, b, c;
long long last;
long long x[50010];
bool isfind = false;

long long check(int i)
{
    int a1 = a * (i + 1) * x[i] * x[i];
    int a2 = (b + 1) * i * x[i];
    int a3 = (c + i);
    return  a1 + a2 + a3;
}

void binsearch(int left, int right)
{
    if (left <= right)
    {
        int mid = (right + left) / 2;
        int temp = check(mid);
        if (temp == 0)
        {
            if (last != 0 && last < (long)mid)
                last = mid;
            else
                last = mid;
            isfind = true;
            return;
        } 
        if(!isfind) binsearch(left, mid - 1);
        if(!isfind) binsearch(mid + 1, right);
    }

    return;
}

void search()
{

    a += last;
    b += last;
    c += last;
    binsearch(1, n);
    return;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i];
    }
    while (1)
    {
        cin >> a >> b >> c;
        isfind = false;
        if (a == 0 && b == 0 && c == 0)
            break;
        else
            search();
        if (isfind)
            cout << last << endl;
    }
    system("pause");
    return 0;
}
